try { var dummy = AnonymousAuth; } catch ( e ) {

/**
 * Anonymous Auth - like all Authentication components listens for onConnect
 * events and authenticates the client. If the client cannot be
 * authenticated the component passes the client to rtcf.authenticationFault(client, fault)
 * along with a message or fault object about the rejection.
 * If the client is authenticated the Authenticaton component calls
 * rtcf.authenticationResult(client, user). 
 * (Also, see the User class.)
 */
function AnonymousAuth(){
	// Do nothing. Use the init method instead.
}

// Required for AS 1 inheritance.
AnonymousAuth.prototype = new RTCFComponent();

/**
 * Setup the onConnect and onAuthenticate listeners - which is all this component needs.
 */
AnonymousAuth.prototype.init = function(){
	// init component properties and its resources here...
	this.rtcf.addListener("onConnect", this);
	this.rtcf.addListener("onAuthenticate", this);
}


/** 
 * We authenticate all connections with any non-empty displayName by creating a User object
 * and calling this.rtcf.authenticationResult(client, user);
 */
AnonymousAuth.prototype.onConnect = function(client, credentials){
	if (typeof credentials.displayName != "string"){
		//trace("Calling authenticationFault> client: " + client);
		this.rtcf.authenticationFault(client, "Invalid data. A credentials.displayName must be passed to the server for an anonymous connection to be accepted.");
		return;
	}
	
	var displayName = credentials.displayName;
	
	// Trim the string so we can check if it is zero length.
	displayName = displayName.replace(/^\s+|\s+$/g,"");
	if (displayName.length == 0){
		this.rtcf.authenticationFault(client, "You must enter a name to connect.");
		return;
	}
	
	// If we've got here we have a display name so we can create a user object with a guest role.
	// This component could keep track of all user names, but we'll let the user manager do that.
	// Another componet, like the user manager, can enforce uniqueness of the displayName
	// if that is required in the onAuthenticate call.
	var user = new User(client.id, displayName);
	user.roles.guest = true;
	user.properties = {
		displayName: displayName,
		id:client.id,
		type:"AnonymousUser"
	}
	this.rtcf.authenticationResult(client, user);
}

/** 
 * We accept all connections by creating a User object
 * and calling this.rtcf.authenticationResult(client, user);
 */
AnonymousAuth.prototype.onAuthenticate = function(client, user){
	this.rtcf.authorizationResult(client, user);
}



} // end catch
